﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using App.Utilities.Web.Handlers;
using CRMBiz;
using Newtonsoft.Json;

namespace CRMWeb.WebServices
{
    /// <summary>
    /// Summary description for AdvancedSearch
    /// </summary>
    public class AdvancedSearch : BaseHandler
    {

        public override void OnMethodInvoke(OnMethodInvokeArgs e)
        {
            context.Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache);
            context.Response.Cache.SetExpires(DateTime.MinValue);
            context.Response.Cache.SetNoStore();

            SetResponseContentType(ResponseContentTypes.HTML);
        }

        public override void AfterMethodInvoke(object result)
        {
            base.AfterMethodInvoke(result);
        }

        //user defined function
        #region private method

        public void DoAdvSearchFunction(string searchtext)
        {
            try
            {
                DataSet ds = ClientProfileHandler.GetAdvancedSearch(1, 1, searchtext);
                string strJson = JsonConvert.SerializeObject(ds.Tables[0]);
                context.Response.Write(strJson);
            }
            catch (Exception)
            {
                throw;
            }
        }

        #endregion
    }
}